#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include "parport.h"

#define NONE     0
#define UP       1
#define DOWN     2
#define FAV      4
#define ONOFF    32
#define POWEROFF 128

void up()         { port_write(UP); }
void down()       { port_write(DOWN); }
void none()       { port_write(NONE); }
void onoff()      { port_write(ONOFF); }
void poweron()    { port_write(NONE); }
void poweroff()   { port_write(POWEROFF); }
void powercycle() { poweroff(); sleep(1); poweron(); }
void reset()      { powercycle(); sleep(1); onoff(); }
void help()
{
        printf("%s [read|write n] #where n is byte to write\n", argv[0]);
}
int main ( int argc, char *argv[] )
{
    int i=1;

    if (!strcmp(argv[i], "up")) { up();} 
    else if (!strcmp(argv[i], "down")) { down();} 
    else if (!strcmp(argv[i], "onoff")) { onoff();} 
    else if (!strcmp(argv[i], "poweron")) { poweron();} 
    else if (!strcmp(argv[i], "poweroff")) { poweroff();} 
    else if (!strcmp(argv[i], "powercycle")) { powercycle();} 
    else if (!strcmp(argv[i], "reset")) { reset();} 
    else if (!strcmp(argv[i], "none")) { none();} 
    else { help();}

    return 0;
}
